package org.example;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.stream.Stream;

public class Steam_Demo1 {
    public static void main(String[] args) {
        //单列集合
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1,"a","b","c","d","e","f");
        list1.stream().forEach(s-> System.out.println(s));
        System.out.println("-----------------1");
        //双列集合 不能直接用Steam流方法 但是可以用keySet()方法获取键的集合 用entrySet()方法获取键值对的集合
        //转化为单列集合
        HashMap<Integer,String> map = new HashMap<>();
        map.put(1,"a");
        map.put(2,"b");
        map.put(3,"c");
        map.put(4,"d");
        map.put(5,"e");
        map.put(6,"f");
        map.entrySet().stream().forEach(s-> System.out.println(s));
        System.out.println("-----------------2");
        //数组
        String[] s={"a","b","c","d","e","f"};
        Arrays.stream(s).forEach(s1-> System.out.println(s1));
        int[] s1={1,2,3};
        Arrays.stream(s1).forEach(s2-> System.out.println(s2));
        System.out.println("------------------3");
        //零散数据
        Stream.of(1,2,3,4,5,6).forEach(s3-> System.out.println(s3));
    }
}
